import React, { PureComponent } from "react";
import styles from "./index.less";

import FlowDataDetail from '../../../../components/flowdataDetail/TemplateIndex';

class FlowHandleDetail extends PureComponent {
  handleExit = () => {
    const { history } = this.props;
    // history.push('/flowimplement/flowhandle');
    if (window.parent !== window) {
      window.parent.postMessage({type: 'back'}, '*');
    } else {
      history.goBack();
    }
  }

  afterSave = (isDraft, params) => {
    if (window.parent !== window) {
      if (isDraft) {
        window.parent.postMessage({type: 'formDraftSaved', data: params}, '*');
      } else {
        window.parent.postMessage({type: 'formSaved', data: params}, '*');
      }
    }
  }

  render() {
    // const { location: { pathname } = {} } = this.props;
    return (
      <div className={styles.root}>
        <FlowDataDetail
          handleExit={this.handleExit}
          afterSave={this.afterSave}
          // showSaveDraft={pathname === '/embedded/todo-detail'}
          showSaveDraft
        />
      </div>
    );
  }
}

export default FlowHandleDetail;